package com.biz.primus.app.rest.feign.order;

import com.biz.primus.app.rest.degraded.order.DegradedOrderFeignClient;
import com.biz.primus.model.order.enums.OrderState;
import com.biz.primus.model.order.vo.request.OrderCodeAndStateVO;
import com.biz.primus.model.order.vo.request.OrderCodeVO;
import com.biz.primus.model.order.vo.request.OrderSummaryRequestVO;
import com.biz.primus.model.order.vo.request.PaidOrderRequestVO;
import com.biz.primus.model.order.vo.response.OrderResponseVO;
import com.biz.primus.model.order.vo.response.OrderSummaryResponseVO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * OrderFeignClient
 *
 * @author Tiger Feng
 * @date 2017年11月16日
 */
@FeignClient(qualifier = "orderFeignClient", name = "service-order", fallback = DegradedOrderFeignClient.class)
public interface OrderFeignClient {
    /**
     * 订单结算接口<br><p>
     * 1.配送地址：用户收货地址；<br>
     * 2.配送方式：同城配送、自提、三方物流；<br>
     * 3.商品促销活动：活动方式去人（商品A送商品B、满x减y）；<br>
     * 4.订单促销活动：<br>
     * 5.优惠券：调用第三方接口计算；<br>
     * 6.支付方式：线上统一（货到付款、微信支付、支付宝支付、电子钱包、银行卡）；<br>
     * 7.发票说明：记录发票信息；</p>
     *
     * @param requestVO
     * @return
     */
    @PostMapping("soa/orderService/settlement")
    OrderSummaryResponseVO settleOrder(
            @RequestBody OrderSummaryRequestVO requestVO);

    /**
     * 创建订单：<br><p>
     * 1、核算订单结算金额等信息；
     * 2、锁定门店商品，
     * 3、创建订单成功，订单状态（待付款
     * </p>
     *
     * @param request
     * @param requestVO
     * @return
     */
    @PostMapping("soa/orderService/create")
    OrderSummaryResponseVO createOrder(
            @RequestBody OrderSummaryRequestVO requestVO);

    /**
     * 根据订单编号获取订单
     *
     * @param orderCodeVO
     * @return
     */
    @PostMapping("soa/orderService/queryByOrderCode")
    OrderResponseVO getByOrderCode(@RequestBody OrderCodeVO orderCodeVO);

    /**
     * 根据订单类型和订单编号查询订单列表<br>
     * <p>查询出的订单列表已创建时间倒序</p>
     *
     * @param orderCodeAndStateVO
     * @return
     */
    @PostMapping("soa/orderService/queryListByOrderStateAndOrderCode")
    List<OrderResponseVO> queryListByOrderStateAndOrderCode(
            @RequestBody OrderCodeAndStateVO orderCodeAndStateVO);

    /**
     * 订单支付完成回调<br>
     * <p>支付完成回调通知订单更改订单状态</p>
     *
     * @param paidOrderRequestVO
     * @return
     */
    @PostMapping("soa/orderService/paidOrderCallback")
    Boolean paidOrderCallback(
            @RequestBody PaidOrderRequestVO paidOrderRequestVO);

    /**
     * 取消订单
     *
     * @param orderCodeVO
     */
    @PostMapping("soa/orderService/cancelOrder")
    void cancelOrder(@RequestBody OrderCodeVO orderCodeVO);
}
